function makeDate(timestamp: number): Date;
function makeDate(m: number, d: number, y: number): Date;
function makeDate(mOrTimestamp: number, d?: number, y?: number): Date {
    if (d !== undefined && y !== undefined) {
        return new Date(y, mOrTimestamp, d);
    } else {
        return new Date(mOrTimestamp);
    }
}

makeDate(12345678);
makeDate(5, 5, 5);
// makeDate(1, 3);

function fn(s: string): void
function fn() {
    // ...
}

fn('1');
// fn(); // 应有 1 个参数，但获得 0 个。

// function len(s: string): number;
// function len(arr: any[]): number;
// function len(x: any) {
//     return x.length;
// }

function len(x: any[] | string) {
    return x.length;
}

len([]);
len('');
len(Math.random() > 0.2 ? 'hello' : []);

//////////////////////////////////////
/// Declaring `this` in Function
//////////////////////////////////////

interface User {
    admin: boolean
}

interface DB {
    filterUsers(filter: (this: User) => boolean): User[]
}

let db!: DB

db.filterUsers(function() {
    return this.admin;
});

export {};